/* eslint-disable max-classes-per-file */
import { JsonProperty, Serializable } from '@/plugins/reflect-metadata';

@Serializable()
export class PlatformConfig {
  @JsonProperty('rate')
    rate: string = '0.01';

  get rateBody() {
    return {
      rate: this.rate,
    };
  }

  @JsonProperty('platformType')
    platformType: string = '';

  get platformTypeBody() {
    return {
      platformType: this.platformType,
    };
  }

  @JsonProperty('syncType')
    syncType: string = '';

  get syncTypeBody() {
    return {
      type: this.syncType,
    };
  }
}

@Serializable()
export class PlatformTypeItem {
  @JsonProperty('name')
    name: string = '';

  @JsonProperty('platformType')
    platformType: string = '';
}

@Serializable()
export class PlatformTypeList {
  @JsonProperty({ name: 'data', type: PlatformTypeItem })
    items: PlatformTypeItem[] = [];

  get total() {
    return this.items.length;
  }

  get platformMap() {
    const obj: Record<string, string> = {};
    this.items.forEach((item) => {
      obj[item.platformType] = item.name;
    });
    return obj;
  }
}
